package job;

import java.io.Serializable;
import java.rmi.RemoteException;

public class JobImpl implements JobItf,Serializable {

	private static final long serialVersionUID = 1L;
	
	int idJob;
	CallBackItf cb;
	
	public JobImpl(int id, CallBackItf cb) {
		this.idJob = id;
		this.cb = cb;
	}

	public void faireJob() {
		new Thread(new ThreadJob(this)).start();
	}
}

class ThreadJob implements Runnable{
	JobImpl leJob;
	
	public ThreadJob (JobImpl leJob){
		this.leJob=leJob;
	}
	
	@Override
	public void run() {
		System.out.println("Youpiii je fait le job " + leJob.idJob +" !!!" );
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		try {
			leJob.cb.finit();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		
	}
	
}